/*
 * @Author: xinyang3
 * @Date: 2021-07-19 15:32
 * @Descripttion: attrs
 * @LastEditors: xinyang3
 * @LastEditTime: 2021-07-19 16:02
 */

// attrs 直接传递到子组件的根元素上
const Child = {
  name: 'child',
  created() {
    console.log(this.$attrs);
  },
  template: `
  <select>
      <option value="1">Yesterday</option>
      <option value="2">Today</option>
      <option value="3">Tomorrow</option>
    </select>`
};

// 子组件根元素不再继承
const Child2 = {
  name: 'child2',
  inheritAttrs: false,
  created() {
    console.log(this.$attrs);
  },
  template: `
  <div class="date-picker">
      <input type="datetime" v-bind="$attrs" />
    </div>`
};

const Parent = {
  name: 'parent',
  methods: {
    showChange(e) {
      console.log(e.target.value);
    }
  },
  data() {
    return {
      activated: true
    }
  },
  components: {
    // DatePicker: Child,
    DatePicker: Child2
  },
  template: `
  <div id="date-picker" class="demo">
    <!-- <date-picker @change="showChange" class="a3"></date-picker> -->
    <date-picker data-status="activated"></date-picker>
  </div>
  `
};

export default Parent;